package com.hm.demo;

import java.util.ArrayList;
import java.util.Collections;

public class StuManage {
    private final ArrayList<Student> stus = new ArrayList<>();
    //这里采用多态的写法，改变功能需求只需要把右边改变
   private final StudentOperator o = new Operator1();

    {
        Collections.addAll(stus, new Student("紫霞仙子", '女', 99), new Student("至尊宝", '男', 89), new Student("蜘蛛精", '女', 87), new Student("春十三娘", '女', 89), new Student("牛夫人", '女', 79));
    }

    public void add(Student student) {
        stus.add(student);
    }
//用接口来写的好处，可以根据功能需要灵活切换
    public void printAll() {
        o.printAll(stus);
    }

    public void printAvg() {
       o.printAvg(stus);
    }

}
